package com.lantosec.hmrp.modules.form.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.form.vo.FormTableVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * <p>
 * 自定义表单表定义
 * </p>
 *
 * @author AutoCode
 * @since 2020-04-15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("form_table")
@ApiModel(value="Table对象", description="自定义表单表定义")
public class FormTable extends BaseEntity<FormTableVO> {

    private static final long serialVersionUID = 1L;

    public FormTable(){}

    public FormTable(FormTableVO vo){
        this.tableId = vo.getTableId();
        this.tableSchema = vo.getTableSchema();
        this.tableName = vo.getTableName();
        this.tableType = vo.getTableType();
        this.tableDef = vo.getTableDef();
        this.tableComment = vo.getTableComment();
        this.parentId = vo.getParentId();
        this.createDate = vo.getCreateDate();
        this.createUserId = vo.getCreateUserId();
        this.createUserName = vo.getCreateUserName();
    }

    @Override
    public FormTableVO convertToVO(){
        return new FormTableVO(this);
    }

    @TableId(value = "table_id", type = IdType.ASSIGN_UUID)
    private String tableId;

    @ApiModelProperty(value = "表所在数据库")
    private String tableSchema;

    @ApiModelProperty(value = "表名")
    private String tableName;

    @ApiModelProperty(value = "表类型，BASE TABLE基本表，VIEW视图")
    private String tableType;

    @ApiModelProperty(value = "表定义，PRIMARY主表，DETAILED明细表")
    private String tableDef;

    @ApiModelProperty(value = "表描述")
    private String tableComment;

    @ApiModelProperty(value = "上级表ID")
    private String parentId;

    @ApiModelProperty(value = "创建时间")
    private Date createDate;

    @ApiModelProperty(value = "创建用户ID")
    private String createUserId;

    @ApiModelProperty(value = "创建用户名称")
    private String createUserName;

    public enum ColName {
        table_id,table_schema,table_name,table_type,table_def,table_comment,parent_id,create_date,create_user_id,create_user_name
    }

}
